/** 
 * @file 2.虚继承.cpp
 * @author 18-工程视觉-黄星照
 * @brief 阅读下列代码，回答代码是否能通过编译，
 *            如可以，请回答代码的输出；
 *            如不行，请回答编译器报错原因，并修改，然后回答代码输出。
 * @date 2020-09-25
 */

/**
 * 不可以
 * 应当指明c.print()为c.A::print() 或 c.B::print()
 * 
 */


#include <iostream>

class A
{
public:
    A()
    {
        ::std::cout << "A constructor.\n";
    }
    ~A()
    {
        ::std::cout << "A destructor.\n";
    }
    virtual void print()
    {
        ::std::cout << "A print.\n";
    }
};

class B
{
public:
    B()
    {
        ::std::cout << "B constructor.\n";
    }
    ~B()
    {
        ::std::cout << "B destructor.\n";
    }
    virtual void print()
    {
        ::std::cout << "B print.\n";
    }
};

class C: public A, public B
{
public:
    C()
    {
        ::std::cout << "C constructor.\n";
    }
    ~C()
    {
        ::std::cout << "C destructor.\n";
    }
};

int main()
{
    C c;
    c.print();
}